#include"stemmer.h"
#include"../../util.h"

Stemmer::Stemmer()
{
}

string Stemmer::stemming(string query)
{
	string res = "";
	vector<string> terms = util::tokenize(query, " ");
	for(int i = 0; i < terms.size(); ++ i)
	{
		string term(terms[i]);
		string out;
		stem_word(term, out);
		if(out.length() > 0)
		{
			res += out;
			res += " ";
		}
	}
	return res;
}

void Stemmer::reform(QueryNode &node)
{
	node.label = stemming(node.label);
}

QueryNode Stemmer::reform_new(QueryNode &node)
{
	QueryNode res(stemming(node.label));
	res.isVirtual = true;
	return res;
}